import requests
import json



url = "https://qianfan.baidubce.com/v2/app/conversation"

payload = json.dumps({
        "app_id": "3d661451-a066-4186-bcb4-d1b57f2bc858"
    })
headers = {
        'Content-Type': 'application/json',
        'X-Appbuilder-Authorization': 'Bearer bce-v3/ALTAK-JF19wDK4Fjm8QVJkSng9F/e8e69f73fa351aeca4c3926e0bca1e15b565b53f'
    }

response = requests.request("POST", url, headers=headers, data=payload)

data = json.loads(response.text)
conversation_id = data['conversation_id']
url = "https://qianfan.baidubce.com/v2/app/conversation/runs"

payload = json.dumps({
    "app_id": "3d661451-a066-4186-bcb4-d1b57f2bc858",
    "query": "你好",
    "stream": False,
    "conversation_id": conversation_id
})
headers = {
    'Content-Type': 'application/json',
    'X-Appbuilder-Authorization': 'Bearer bce-v3/ALTAK-JF19wDK4Fjm8QVJkSng9F/e8e69f73fa351aeca4c3926e0bca1e15b565b53f'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

data = json.loads(response.text)
conversation_id = data['answer']


